package com.hdd.utils;

import com.baidu.aip.contentcensor.AipContentCensor;
import com.baidu.aip.contentcensor.EImgType;
import org.json.JSONObject;

public class BaiduUtils {

    public static final String APP_ID = "23939262";
    public static final String API_KEY = "yGgdPEynvbOzAdNokDCoBnYV";
    public static final String SECRET_KEY = "MTKi0ahdS24LxbrqCTLhvivyDsuTCGbs";

    /**
     * 百度图片审核
     * @return
     */
    public static boolean check(String url){
        AipContentCensor client = new AipContentCensor(APP_ID, API_KEY, SECRET_KEY);
        JSONObject response = client.imageCensorUserDefined(url, EImgType.URL, null);
        System.out.println(response.toString());
        if("合规".equals(response.getString("conclusion"))&&"1".equals(response.getBigInteger("conclusionType").toString())){
            return true;
        }
       return false;
    }

    public static void main(String[] args) {
        BaiduUtils.check("https://qiniu.17huaduoduo.com/FuQB0rJUF1tvgFElrk1Xe6ieQ8YI");
    }




}
